﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace Client
{
    public partial class SaveFile : Form
    {
        private Thread t = null;
        public event SaveFileEventHandler OnSaveFile = null;
        public SaveFile()
        {
            InitializeComponent();
        }

        private void ShowFolderBrowseDialog()
        {
            if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                this.tbxPath.Text = this.folderBrowserDialog1.SelectedPath;                
            }
            if (this.t != null)
            {
                this.t.Abort();
            }
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            this.t = new Thread(new ThreadStart(ShowFolderBrowseDialog));
            this.t.Start();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.OnSaveFile != null)
            {
                this.OnSaveFile(this, new SaveFileEventArgs(this.folderBrowserDialog1.SelectedPath));
            }
        }

        private void SaveFile_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (this.t != null)
            {
                this.t.Abort();
            }
        }
    }
}
